package com.by.service.impl;

import cn.hutool.core.map.MapUtil;
import com.by.bean.Product;
import com.by.bean.ProductHistory;
import com.by.common.bean.PageBean;
import com.by.common.crud.BaseMapper;
import com.by.common.crud.BaseServiceImpl;
import com.by.common.utils.Assert;
import com.by.mapper.ProductBannerMapper;
import com.by.mapper.ProductHistoryMapper;
import com.by.mapper.ProductMapper;
import com.by.service.ProductHistoryService;
import com.by.service.ProductService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.util.List;
import java.util.Map;

@Service
public class ProductHistoryServiceImpl extends BaseServiceImpl<ProductHistory, ProductHistoryMapper> implements ProductHistoryService {

    /**
     * 查询历史浏览记录
     * @param map
     * @return
     */
    @Override
    public PageBean queryHistory(Map<String, Object> map) {
        int page = MapUtil.getInt(map, "page");
        int pageSize = MapUtil.getInt(map, "pageSize");

        PageHelper.startPage(page, pageSize);
        List<Map> list = baseMapper.queryHistory(map);

        PageInfo info = new PageInfo(list);

        return new PageBean(page, pageSize, info.getTotal(), list);
    }


}


